cmake_minimum_required(VERSION 3.20)
set(DEPENDS_LIB "")

find_package(OpenSSL REQUIRED)
if(OPENSSL_FOUND)
    list(PREPEND DEPENDS_LIB openssl::openssl)
endif()

find_package(workflow REQUIRED)
if(workflow_FOUND)
    list(PREPEND DEPENDS_LIB workflow::workflow)
endif()

find_package(fmt REQUIRED)
if(fmt_FOUND)
    list(PREPEND DEPENDS_LIB fmt::fmt)
endif()

find_package(PahoMqttCpp REQUIRED)

find_package(ZLIB REQUIRED)
if(ZLIB_FOUND)
    list(PREPEND DEPENDS_LIB ZLIB::ZLIB)
endif()

find_package(toml11 REQUIRED)
if(toml11_FOUND)
    list(PREPEND DEPENDS_LIB toml11::toml11)
endif()

find_package(SQLiteCpp REQUIRED)
if(SQLiteCpp_FOUND)
    list(PREPEND DEPENDS_LIB SQLiteCpp)
endif()

find_package(handy REQUIRED)
if(handy_FOUND)
    list(PREPEND DEPENDS_LIB handy::handy)
endif()

find_package(nlohmann_json REQUIRED)
if(nlohmann_json_FOUND)
    list(PREPEND DEPENDS_LIB nlohmann_json::nlohmann_json)
endif()

find_package(PCL REQUIRED)
if(PCL_FOUND)
message(STATUS ${PCL_INCLUDE_DIR})
    list(PREPEND DEPENDS_LIB PCL::PCL)
endif()

find_package(glog REQUIRED)
if(glog_FOUND)
    list(PREPEND DEPENDS_LIB glog::glog)
endif()


set(APPNAME hhconvert2ply)
aux_source_directory(. SRC)
add_executable(${APPNAME} ${SRC})
target_link_libraries(${APPNAME} ${DEPENDS_LIB} )
target_include_directories(${APPNAME} PUBLIC ${PCL_INCLUDE_DIR})
target_precompile_headers(${APPNAME} PUBLIC stdafx.h)

add_custom_command(
    TARGET ${APPNAME}
    POST_BUILD
    COMMAND ${CMAKE_STRIP}  $<TARGET_FILE:${APPNAME}>
)